<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>客 户 添 加</title>
<meta name="renderer" content="webkit">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width, initial-scale=1, maximum-scale=1">
<link rel="stylesheet"
	href="<%=request.getContextPath()%>/resource/layui/css/layui.css"
	media="all">
<script type="text/javascript"
	src="<%=request.getContextPath()%>/resource/js/jquery-3.6.0.min.js"></script>

</head>
<body>

	<fieldset class="layui-elem-field layui-field-title"
		style="margin-top: 20px;">
		<legend>客 户 添 加</legend>
	</fieldset>

	<form class="layui-form" action="">

		<div class="layui-form-item">
			<label class="layui-form-label">客户名称</label>
			<div class="layui-input-inline">
				<input type="text" name="customerName" lay-verify="customerName"
					autocomplete="off" class="layui-input">
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">客户全称</label>
			<div class="layui-input-inline">
				<input type="text" name="customerFullName" lay-verify="customerFullName"
					autocomplete="off" class="layui-input">
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">地址</label>
			<div class="layui-input-inline">
				<input type="text" name="address"
					lay-verify="address" autocomplete="off"
					class="layui-input">
			</div>
		</div>
		
		<div class="layui-form-item">
			<label class="layui-form-label">传真</label>
			<div class="layui-input-inline">
				<input type="text" name="fax"
					lay-verify="fax" autocomplete="off"
					class="layui-input">
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">邮箱</label>
			<div class="layui-input-inline">
				<input type="text" name="email"
					lay-verify="email" autocomplete="off"
					class="layui-input">
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">经理姓名</label>
			<div class="layui-input-inline">
				<input type="text" name="managerName"
					lay-verify="managerName" autocomplete="off"
					class="layui-input">
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">联系电话</label>
			<div class="layui-input-inline">
				<input type="text" name="telephone"
					lay-verify="telephone" autocomplete="off"
					class="layui-input">
			</div>
		</div>

		<div class="layui-form-item">
			<label class="layui-form-label">客户状态</label>
			<div class="layui-input-block">
				<input type="radio" name="status" value="有效客户" title="有效客户" checked="">
				<input type="radio" name="status" value="无效客户" title="无效客户">
			</div>
		</div>
		
		<div class="layui-form-item">
			<label class="layui-form-label">备注</label>
			<div class="layui-input-inline">
				<input type="text" name="demo"
					lay-verify="demo" autocomplete="off"
					class="layui-input">
			</div>
		</div>

		<div class="layui-form-item">
			<div class="layui-input-block">
				<button type="submit" class="layui-btn" lay-submit=""
					lay-filter="submitButton">立即提交</button>
				<button type="reset" class="layui-btn layui-btn-primary">重置</button>
			</div>
		</div>
	</form>

	<script src="<%=request.getContextPath()%>/resource/layui/layui.js"
		charset="utf-8"></script>

	<script>
		layui
				.use(
						[ 'form', 'layedit','laydate' ],
						function() {
							var form = layui.form, layer = layui.layer, laydate = layui.laydate;

							//自定义验证规则
							form.verify({
								username : function(value) {
									if (value.length < 4) {
										return '用户名至少需要4个字符';
									} else if (value.length > 12) {
										return '用户名不能超出12个字符';
									}
								},
								pass : [ /^[\S]{4,12}$/, '密码必须4到12位，且不能出现空格' ],
								nickname : [ /^[\S]{2,16}$/,
										'昵称必须2到16位，且不能出现空格' ],
								age : function(value) {
									if (value < 0) {
										return '年龄不能小于0';
									} else if (value > 200) {
										return '年龄不能大于200';
									} else if (/^\d+$/.test(value) == false) {
										return '年龄必须是整数'
									}
								}
							});

							//监听提交
							form.on('submit(submitButton)', function(data) {
								$.post("adds",data.field, function(obj) {
									if (obj.result == 1) {
										layer.msg(obj.msg, {
											icon : 1,
											time : 2000
										});
										return false;
									} else {
										layer.msg(obj.msg, {
											icon : 2,
											time : 2000
										});
										return false;
									}
								});

								return false;
							});
							
						});
	</script>


</body>
</html>